﻿using System.Collections.Generic;
using System.Linq;
using Dosimetria.Models;
using Dosimetria.Models.DataAnnotations_Classes.Authentication;
using Dosimetria.Security;
using Dosimetria.DAL;
using Dosimetria.Models.DataAnnotations_Classes;
using System.Data;
using System;

namespace Dosimetria.Authorization
{
    public static class Membership
    {
        private static Querys db = new Querys();
        public static bool ValidateUser(Login Login)
        {
           // Login.Password = Encryption.encryptSHA1(Login.Password);

            var lUser = db.getDataUsuarioByUsuarioAndPassword(Login.UsernName, Login.Password);
          
            if(lUser.Count == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public static List<Sistema> GetFuncionalidades(string userName)
        {
            var lSistemas = db.GetFuncionalidades(userName);
            foreach(Sistema sist in lSistemas)
            {
                sist.funcionalidades = db.getFuncionalidadesByUserNameAndSistemaID(userName, sist.id);
            }
            return lSistemas;
        }


    }
}